package com.itcast.stargraph.controller;

import com.itcast.stargraph.dto.common.Result;
import com.itcast.stargraph.dto.request.Text2ImageReqDto;
import com.itcast.stargraph.dto.respone.Text2ImageResDto;
import com.itcast.stargraph.service.TextToImageService;
import com.itcast.stargraph.utils.UserThreadLocalUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api/authed/1.0/t2i")
public class TextToImageController {
    
    @Autowired
    private TextToImageService textToImageService;
    
    @PostMapping("/list")
    public String list() {
        System.out.println("用户ID是："+UserThreadLocalUtils.getUser().getId());
        return "hello";
    }
    
    /**
     * 添加comfyui流程任务（工作流任务）
     * @param dto
     * @return
     */
    @PostMapping("/prompt")
    public Result<Text2ImageResDto> prompt(@RequestBody Text2ImageReqDto dto) {
        
        Text2ImageResDto resDto = textToImageService.prompt(dto);
        return Result.ok(resDto);
    }
}